/* 
 * Copyright 2011 kOSMik.
 * This file is part of kOSMik.
 * 
 * kOSMik is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * kOSMik is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with kOSMik.  If not, see <http://www.gnu.org/licenses/>.
 *  
 * kOSMik:
 * Open Street Map - Editor.
 * http://code.google.com/p/swp-dv-ws2010-osm-2/
 */

package de.fuberlin.kosmik.gui.activity;

import org.mapsforge.android.maps.MapActivity;

import android.os.Bundle;
import de.fuberlin.kosmik.data.DataBaseConnector;
import de.fuberlin.kosmik.data.DataBaseConnectorImpl;
import de.fuberlin.kosmik.trackrecorder.TrackRecorderService;

/**
 * Provides basic functionality such as the connection to the TrackService or
 * DatabaseWrapper.
 * 
 * @author Johannes
 * @see StartActivity
 * @see ViewActivity
 * @see TrackRecorderService
 * @see DataBaseConnector
 * 
 */
public abstract class TrackActivity extends MapActivity {

	private DataBaseConnector dataBase;

	/**
	 * Get the TrackRecorderService.
	 * 
	 * @return a static reference to the TrackRecorderService instance.
	 */
	protected TrackRecorderService getTrackService() {
		return TrackRecorderService.getService(this);
	}

	/**
	 * Get the Databaseconnector..
	 * 
	 * @return a static reference to the Databaseconnector.
	 */
	public DataBaseConnector getDataBase() {
		dataBase.reopen();
		return dataBase;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		dataBase = new DataBaseConnectorImpl(this);
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		dataBase.close();
	}

}
